﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using WebProject.Core.Models;

namespace WebProject.Models
{
    public class ProductionTypeModel
    {
        public ProductionTypeModel()
        {
            
        }

        public ProductionTypeModel(ProductionType productionType)
        {
            Id = productionType.Id;
            TypeName = productionType.TypeName;
        }

        public int Id
        {
            get; set;
        }

        [Required(ErrorMessage = "{0}不能为空")]
        [StringLength(40, ErrorMessage = "{0}的最大长度为{1}个字符。")]
        [DisplayName("产品类名")]
        public string TypeName
        {
            get; set;
        }

        public ProductionType ToProductionType()
        {
            return new ProductionType
                {
                    Id = Id,
                    TypeName = TypeName
                };
        }
    }
}